<template>
  <div class="login_container">
    <div class="login">
      <div class="login-screen">

        <div class="login-form">
          <div class="control-group">
            <input v-model="username" type="text" placeholder="请输入用户名" @input="handleInput" checked />
          </div>

          <div class="control-group">
            <input v-model="passwords" type="password" placeholder="请输入密码" @keyup.enter="userLogin" />
          </div>

          <!-- <a class="btn btn-primary btn-large btn-block" href="#" style="background:#1475B1" @click="userLogin">登录</a> -->
          <el-button type="primary" :loading="loading" style="background:#1475B1;width:86%;height:50px;font-size:16px"  @click="userLogin">登录</el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      ts: this.newStore(),
      username: '',
      passwords: '',
      loading:false,
    }
  },

  layout: 'default2',
  methods: {
    handleInput(e) {
      this.username = e.target.value.replace(/[\W]/g, '')
    },
    userLogin() {
      if (this.username == '') {
        this.$message.error('请填写用户名')
        return
      }
      if (this.passwords == '') {
        this.$message.error('请填写密码')
        return
      }
      this.loading=true;
      const res = {
        username: this.username,
        password: this.passwords
      }

      this.spost(this.ts, '/anon/ajaxlogin', res).then(ts => {
        sessionStorage.setItem('token', ts.d.token)
        sessionStorage.setItem('username', ts.d.user.username)
        this.loading=false
        this.$router.push('/SystemHome2')
      })
    }
  }
}
</script>

<style scoped>
.login_container {
  background: url('../static/img/loginbg.png');
  width: 100%;
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  min-height: 100%;
  height: auto;
  z-index: -100;
  background-size: cover;
}
.login {
  position: fixed;
  right:100px;
  top: 20%;
  width: 560px;
  height: 480px;
  background: url('../static/img/logodiv2.png') no-repeat;
  background-size: cover;
}
.login-screen {
  padding: 50px;
  border-radius: 5px;
  width: 100%;
  margin: 100px auto;
  position: relative;
  top: 70px;
}

.app-title {
  text-align: center;
  color: #777;
  margin-bottom: 20px;
}

.login-form {
  text-align: center;
}
.control-group {
  margin-bottom: 10px;
}

.control-group input {
  text-align: center;
  background:rgba(0,0,0,0.2);
  border: 2px solid transparent;
  border-radius: 3px;
  font-size: 16px;
  font-weight: 200;
  padding: 16px 0;
  width: 400px;
  color: #fff;
  transition: border 0.5s;
}
::-webkit-input-placeholder { /* WebKit browsers */
  color: #aaa;
  font-size: 16px;
}

::-moz-placeholder { /* Mozilla Firefox 19+ */
  color: #aaa;
  font-size: 16px;
}

:-ms-input-placeholder { /* Internet Explorer 10+ */
  color: #aaa;
  font-size: 16px;
}  
.btn {
  background: #4fa0d8;
  color: #ffffff;
  font-size: 16px;
  line-height: 25px;
  padding: 16px 0;
  text-decoration: none;
  text-shadow: none;
  border-radius: 3px;
  box-shadow: none;
  transition: 0.25s;
  display: block;
  width: 400px;
  margin: 0 auto;
}

.btn:hover {
  background-color: #2980b9;
}

.login-link {
  font-size: 12px;
  color: #444;
  display: block;
  margin-top: 12px;
}
.el-button:hover{
  background: #2980b9;
}
</style>
